package cn.com.nes.common.util.tree;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
public class TreeNode<T> {

    /**
     * 节点ID
     */
    private String id;

    /**
     * 节点名称
     */
    private String name;

    /**
     * 前台显示节点名称
     */
    private String label;

    /**
     * 父节点ID
     */
    private String parentId;

    /**
     * 父节点名册
     */
    private String parentName;

    /**
     * 是否是叶子节点
     */
    private Boolean leaf = false;

    /**
     * 子节点列表
     */
    private List<T> children = new ArrayList<T>();

    public TreeNode(String id, String name, String parentId) {
        this.id = id;
        this.name = name;
        this.label = name;
        this.parentId = parentId;
    }

    public void setName(String name) {
        this.name = name;
        this.label = name;
    }

}
